package com.ims.controller;

import com.ims.pojo.Menu;
import com.ims.service.MenuService;
import com.ims.util.Result;
import com.ims.util.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author: zk
 * @date: 2022/9/3 16:02
 */
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    /**
     * 根据用户id查询菜单列表
     * @param userId
     * @return
     */
    @GetMapping("/findAll/{id}")
    public Result<List<Menu>> findAllByUserId(@PathVariable(name = "id") Integer userId) {
        List<Menu> menuList = menuService.selectMenuListById(userId);
        return new Result<>(true, StatusCode.OK, "根据用户id查询菜单列表成功", menuList);
    }
}
